import 'package:coinbaby/common/const/cosnt.dart';
import 'package:coinbaby/common/textstyle/textstyle.dart';
import 'package:flutter/material.dart';

class HomeMoneyView extends StatefulWidget {
  @override
  _HomeMoneyViewState createState() => _HomeMoneyViewState();
}

class _HomeMoneyViewState extends State<HomeMoneyView> {

  static const List<String> titles = ["点卡余额＞", "交易收益＞", "推广收益＞"];
  
  bool ishidden = false;

  List<Widget> _createChild() {
    return titles.map((e) => _MoneyItems(title: e, val: ishidden ? "****" : "1234.26",)).toList();
  }
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(15.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            children: <Widget>[
              Text("交易总资产", style: AppFont.textStyle(14, AppColor.font666,family: FamilyEnum.medium),),
              InkWell(
                onTap: (){
                  setState(() {
                    ishidden = !ishidden;
                  });
                },
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 5),
                  child: Icon(ishidden ? Icons.visibility_off : Icons.visibility, color: const Color(0xff535353),),
                ),
              )
            ],
          ),
          SizedBox(height: 5,),
          Text(ishidden ? "****" : "233,333.66 USDT", style: AppFont.textStyle(25, AppColor.font333),),
          Spacer(),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: _createChild()
          )
        ],
      ),
    );
  }
}

class _MoneyItems extends StatelessWidget {
  final String title;
  final String val;

  const _MoneyItems({Key key, this.title, this.val}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Text(title, style: AppFont.textStyle(11, AppColor.font666),),
        SizedBox(height: 10,),
        Text(val, style: AppFont.textStyle(15, AppColor.font333, family: FamilyEnum.medium),)
      ],
    );
  }
}